package hotel.switchs.oversea.biz.controller;

import com.alibaba.fastjson.JSONObject;
import hotel.base.oversea.constant.enums.CommonEnums;
import hotel.base.oversea.controller.BaseController;
import hotel.base.oversea.utils.Result;
import hotel.switchs.oversea.biz.config.service.RedisService;
import hotel.switchs.oversea.biz.service.SwitchCreateSubHotelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 携程校验后酒店，创建子酒店
 * @author Zhang·JZ
 * @date 2020-05-28
 */
@Slf4j
@RestController
@RequestMapping("/switchCreateSubHotel")
@Api(value = "SwitchCreateSubHotelController", tags = {"携程校验后酒店，创建子酒店"})
public class SwitchCreateSubHotelController extends BaseController {

    @Autowired
    private SwitchCreateSubHotelService switchCreateSubHotelService;

    @Autowired
    private RedisService redisService;

    /**
     * 根据母酒店id 创建后存储子酒店数据,并更新子酒店相关属性
     *
     * @return
     */
    @PostMapping("/addSwitchCreateSubHotel")
    @ApiOperation(value = "根据母酒店id 创建后存储子酒店数据,并更新子酒店相关属性")
    @ApiImplicitParam(name = "addSwitchCreateSubHotel", value = "根据母酒店id 创建后存储子酒店数据,并更新子酒店相关属性", required = true, dataType = "String")
    public Result addSwitchCreateSubHotel(@RequestBody JSONObject jsonObject) {
        String masterHotelId = jsonObject.getString("masterHotelId");
        if(ObjectUtils.isEmpty(jsonObject.get("masterHotelId"))){
            return new Result(false, CommonEnums.FIELD_NULL.getMsg());
        }

        return switchCreateSubHotelService.saveSubHotel(masterHotelId);
    }
    /**
     * 根据母酒店id 创建后存储子酒店数据,并更新子酒店相关属性 + 并获取子酒店详情
     *
     * @return
     */
    /*@PostMapping("/addSwitchCreateSubHotelAndGetSubInfo")
    @ApiOperation(value = "根据母酒店id 创建后存储子酒店数据,更新子酒店相关属性，并获取子酒店详情")
    @ApiImplicitParam(name = "addSwitchCreateSubHotelAndGetSubInfo", value = "根据母酒店id 创建后存储子酒店数据,更新子酒店相关属性，并获取子酒店详情", required = true, dataType = "String")
    public Result addSwitchCreateSubHotelAndGetSubInfo(@RequestBody JSONObject jsonObject) {
        String masterHotelId = jsonObject.getString("masterHotelId");
        if(ObjectUtils.isEmpty(jsonObject.get("masterHotelId"))){
            return new Result(false, CommonEnums.FIELD_NULL.getMsg());
        }

        return switchCreateSubHotelService.saveSubHotelAndGetSubInfo(masterHotelId);
    }*/





}
